package cn.com.cmbc.config;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;

import java.io.IOException;

public class HBaseConfig {
    @Value("${hbase.zookeeper.quorum}")
    private String quorum;
    @Value("${hbase.zookeeper.property.clientPort}")
    private String port;
    @Bean
    public Connection hbaseConnection() throws IOException {
        quorum = ClusterConfig.HBASELIST;
        port = "2181";

        Configuration config = HBaseConfiguration.create();
        config.set("hbase.zookeeper.quorum", quorum);
        config.set("hbase.zookeeper.property.clientPort", port);
        return ConnectionFactory.createConnection(config);
    }
}
